<template>
  <div>
    <div>
      <van-grid :gutter="10" :column-num="3">
        <van-grid-item
          v-for="value in values"
          :key="value.name"
          :icon="value.icon"
          :text="value.text"
          @click="onClick(value)"
        />
      </van-grid>
    </div>
  </div>
</template>

<script>
import HomeMixin from './homeMixin'

import menus from '../erp/menus'

export default {
  name: 'HomeMe',
  components: {},
  mixins: [HomeMixin],

  data() {
    return {
      //

      values: []
    }
  },
  computed: {},
  async created() {
    console.log(' menus, ', menus)
    this.init()
  },

  methods: {
    init() {
      const items = Object.keys(menus).map(item => {
        // console.log(item, menus[item])
        const { text, icon } = menus[item]
        const path = {
          path: '/erp/menus',
          query: { menu: item }
        }
        return { name: item, text, icon, path }
      })
      console.log(items)
      this.values = items
    },
    onClick(item) {
      console.log('item', item)
      this.$router.push(item.path)
    },

    onTest() {
      this.$router.push({
        path: '/erp/contacts',
        query: { id: 1, model: 'sdasdad' }
      })
    }
  }
}
</script>

<style type="text/css"></style>
